package com.hospital.hospitalsystem.modules.doctor.controller;

import com.hospital.hospitalsystem.base.BaseResponse;
import com.hospital.hospitalsystem.config.TokenVerify;
import com.hospital.hospitalsystem.modules.doctor.biz.DoctorBiz;
import com.hospital.hospitalsystem.modules.doctor.dto.MessageBookUuidReq;
import com.hospital.hospitalsystem.modules.doctor.dto.PrescriptionReq;
import com.hospital.hospitalsystem.modules.doctor.dto.PrescriptionRsp;
import com.hospital.hospitalsystem.utils.LoginUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author qiancheng
 * @date 2023/4/27
 */
@RestController
@RequestMapping("/prescription")
@Api(tags = "药方管理")
@Validated
public class PrescriptionController {

    @Autowired
    private LoginUtils loginUtils;

    @Autowired
    private DoctorBiz doctorBiz;

    @ApiOperation(value = "根据bookUuid获取药方详情")
    @RequestMapping(path = "/prescription-bookUuid-get",method = RequestMethod.POST)
    @TokenVerify(type = "doctor,user,medicine")
    public BaseResponse prescriptionBookUuid(@RequestBody MessageBookUuidReq req){
        PrescriptionRsp result = doctorBiz.prescriptionBookUuid(req);
        return BaseResponse.success(result);
    }

    @ApiOperation(value = "根据bookUuid修改药方详情")
    @RequestMapping(path = "/prescription-bookUuid-update",method = RequestMethod.POST)
    @TokenVerify(type = "doctor")
    public BaseResponse prescriptionBookUuidUpdate(@RequestBody PrescriptionReq req){
        doctorBiz.prescriptionBookUuidUpdate(req);
        return BaseResponse.success();
    }

    @ApiOperation(value = "根据bookUuid增加药方详情")
    @RequestMapping(path = "/prescription-bookUuid-add",method = RequestMethod.POST)
    @TokenVerify(type = "doctor")
    public BaseResponse prescriptionBookUuidAdd(@RequestBody PrescriptionReq req){
        doctorBiz.prescriptionBookUuidAdd(req);
        return BaseResponse.success();
    }

    @ApiOperation(value = "根据bookUuid删除药方详情")
    @RequestMapping(path = "/prescription-bookUuid-delete",method = RequestMethod.POST)
    @TokenVerify(type = "doctor")
    public BaseResponse prescriptionBookUuidDelete(@RequestBody PrescriptionReq req){
        doctorBiz.prescriptionBookUuidDelete(req);
        return BaseResponse.success();
    }
}
